import { deleteLibrary, libraryList, libraryThrough, reject } from "@/api/service/library/library";
import { RejectData } from "@/api/service/library/types";

import { Message } from "@arco-design/web-vue";
import { reviewData, reviewKeys, reviewQuery } from "./data";

export const getLibraryList = async () => {
  reviewData.value.loading = true;
  const data = await libraryList(reviewQuery.value);
  reviewData.value.data = data.rows;
  reviewQuery.value.total = data.total;
  reviewData.value.loading = false;
};

export const delLibrary = async (id?: string) => {
  const ids = id ? [id] : reviewKeys.value;
  const data = await deleteLibrary(ids);
  Message.success(data.msg);
  getLibraryList();
};

export const allow = async (id?: string) => {
  const ids = id ? [id] : reviewKeys.value;
  await libraryThrough(ids);
  getLibraryList();
  reviewKeys.value = [];
};
export const rejectLib = async (data: RejectData) => {
  await reject(data);
  getLibraryList();
};
